//
//  ViewController.m
//  UI04_01作业
//
//  Created by dllo on 16/6/9.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (nonatomic,assign)CGFloat number;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self createBackgroundImageView];
    [self createSlider];
    [self createBzombieImageView];
    NSLog(@"%.2f",self.slider.value);
    
}
- (void)createBackgroundImageView{
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.frame];
    imageView.image = [UIImage imageNamed:@"BackGround"];
    [self.view addSubview:imageView];
}
- (void)createBzombieImageView{
    self.bzombieImageView = [[UIImageView alloc] initWithFrame:CGRectMake(150, 100, 100, 100)];
    [self.view addSubview:_bzombieImageView];
    
    NSMutableArray *bzombieArray = [NSMutableArray array];
    for (NSInteger i = 1; i <= 25; i++) {
        NSString *string = [NSString stringWithFormat:@"BZombie%ld.tiff",i];
        UIImage *image = [UIImage imageNamed:string];
        [bzombieArray addObject:image];
    }
    _bzombieImageView.animationImages = bzombieArray;
    _bzombieImageView.animationRepeatCount = 0;
   [_bzombieImageView startAnimating];
    [_bzombieImageView release];
}
- (void)createSlider{
    self.slider = [[UISlider alloc] initWithFrame:CGRectMake(150, 500, 150, 30)];
    _slider.minimumValue = 0;
    _slider.maximumValue = 50;
    [_slider addTarget:self action:@selector(didClickedSlider:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:_slider];
}
- (void)didClickedSlider:(UISlider *)slider{
    
    _bzombieImageView.animationDuration = 1 - slider.value / 50;
    [_bzombieImageView startAnimating];
//    NSLog(@"%lf",_bzombieImageView.animationDuration);

    
   }
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
